
//获取应用实例
const app = getApp();
var commonData = require('../../data/data.js');
Page({
  data: {
    dataList: [],
    height: 0,
    pageIndex: 0,
    isHasNext: true
  },
  requestDataList: function () {
    if (!this.data.isHasNext)
      return;
    var that = this;
    wx.showLoading({
      title: '读取中 ',
    })
    wx.request({
      url: app.appSetting.host + "weixin/GetUserRankings?pageIndex=" + this.data.pageIndex + "&nickName=",
      data: {
      },
      header: {
        'content-type': 'application/json' // 默认值
      },
      success: function (res) {
        console.log(res);
        wx.hideLoading();
        if (res.data.Status == 0) {
          that.setData({
            pageIndex: that.data.pageIndex + 1,
            dataList: that.data.dataList.concat(res.data.Result),
            isHasNext: res.data.Result.length>=30,
            height: commonData.screenInfo.height
          });
        } else {
          app.showMsg(res.data.Message);
        }

      }
    })
  },

  onLoad: function () {
    //this.requestDataList();
    this.getSystermMsg();
  },
  //获取屏幕高度，宽度
  getSystermMsg: function () {
    var that = this;
    wx.getSystemInfo({
      success: function (res) {
        commonData.screenInfo.height = res.windowHeight;
        that.setData({
          height: res.windowHeight
        })
      }
    })
  },
  onShow: function () {
    this.requestDataList();
  },

  showUserPower:function(e){
    wx.navigateTo({
      url: 'UserCat?userId='+e.currentTarget.dataset.userid,
    })
  },

})
